<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    * {
        padding: 0;
        margin: 0;
    }

    html,
    body {
        font-family: '微软雅黑';
    }

    .contain {
        width: 320px;
        margin: 5px auto;
        border: 1px solid #2a65ba;
        position: absolute;
        top: 100px;
        left: 100px;
    }

    .gameList {
        list-style: none;
    }

    .gameList li {
        padding-left: 15px;
        line-height: 40px;
        height: 40px;
        font-size: 12px;
        color: #000;
        border-bottom: 1px #aaaaaa dashed;
    }

    h2 {
        font-size: 16px;
        padding-left: 20px;
        line-height: 40px;
    }
</style>

<body>
    <div class="contain">
        <div>
            <img src="../img/winter.jpg" alt="奥运五环标志" width="320" height="198">
        </div>
        <h2>祝福冬奥</h2>
        <ul class="gameList">
            <li> 贝克汉姆：衷心希望北京能够申办成功！</li>
            <li> 姚明：北京申冬奥是个非常棒的机会！加油！</li>
            <li> 张虹：北京办冬奥，大家的热情定超乎想象！ </li>
            <li> 肖恩怀特：我爱北京，支持北京申办冬奥会！</li>
        </ul>
    </div>
</body>
<script src="../js/jq-1.12.4.js"></script>
<script>
    //end()的用法
    $(function () {
        $(".gameList>li").first().css("background-color", "#b8e7f9").end().last().css("background-color", "#f8e7f9").end().eq(1).css("background-color", "yellow")
    })

    //键盘事件
    $(function () {
        $(document).keydown(function (e) {
            let keyCode = e.keyCode
            let obj = $(".contain").offset()
            let left = obj.left
            let top = obj.top
            if (keyCode === 39) {
                left += 10
            } else if (keyCode === 37) {
                left -= 10
            } else if (keyCode === 38) {
                top -= 10
            } else if (keyCode === 40) {
                top += 10
            }
            $(".contain").css({
                "left": left + "px",
                "top": top + "px"
            })
        })
    })
</script>

</html>